\chapter{Editor} \label{editor}

The editor is a vi clone. Launch it by entering \texttt{s" foo" vi} in the interpreter (foo being the file you want to edit). For more info about vi style editing, see \href{http://www.vim.org}{the Vim web site}.

The position of the editor buffer is controlled by the variable \texttt{bufstart}. The default address is \$4000.

\section{Key Presses}

\subsection{Inserting Text}
Following commands enter insert mode. Insert mode allows you to insert text. It can be exited by pressing $\leftarrow$.
\begin{description}
\item[i] Insert text.
\item[a] Append text.
\item[o] Open new line after cursor line.
\item[O] Open new line on cursor line.
\item[cw] Change word.
\end{description}

\subsection{Navigation}
\begin{description}
\item[hjkl] Cursor left, down, up, right.
\item[Cursor Keys] ...also work fine.
\item[U] Half page up.
\item[D] Half page down.
\item[b] Go to previous word.
\item[w] Go to next word.
\item[0] Go to line start.
\item[\$] Go to line end.
\item[g] Go to start of file.
\item[G] Go to end of file.
\end{description}

\subsection{Saving \& Quitting}

After quitting, the editor can be re-opened with Forth command \texttt{fg}, and it will resume operations with the edit buffer preserved.

\begin{description}
\item[ZZ] Save and exit.
\item[:q] Exit.
\item[:w] Save. (Must be followed by return.)
\item[:w!filename] Save as.
\item[F7] Compile and run editor contents.
\end{description}

\subsection{Text Manipulation}
\begin{description}
\item[r] Replace character under cursor.
\item[x] Delete character.
\item[X] Backspace-delete character.
\item[dw] Delete word.
\item[dd] Cut line.
\item[p] Paste line below cursor position.
\item[P] Paste line on cursor position.
\item[J] Join lines.
\end{description}
